<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
	<c:set var="ctx" value="${pageContext.request.contextPath}" />
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>供应商列表</title>
	<jsp:include page="../../import.jsp" flush="true" />
</head>
<!-- 是否显示提交按钮 -->
<sys:funcAuth resCd="SplSubmit">
	<span id="isShowCmtBtn" />
</sys:funcAuth>
<!-- 黑名单设置权限 -->
<sys:funcAuth resCd="blacklist">
	<span id="blackList" />
</sys:funcAuth>
<!-- 是否显示审核按钮 -->
<sys:funcAuth resCd="SplCheck">
	<span id="isShowAudBtn" />
</sys:funcAuth>
<!-- 是否显示修改供应商配置按钮 -->
<sys:funcAuth resCd="SplConfig">
	<span id="isShowConfigBtn" />
</sys:funcAuth>
<!-- 是否显示修改供应商配置按钮 -->
<sys:funcAuth resCd="SplBizFlowMdf">
	<span id="isShowSplBizFlowMdfBtn" />
</sys:funcAuth>

<sys:funcAuth resCd="isSpeModify">
	<span id="isSpeModify" />
</sys:funcAuth>
<sys:funcAuth resCd="isMdfBigCustomer">
	<span id="isMdfBigCustomer" />
</sys:funcAuth>

<!--是否显示变更按钮-->
<sys:funcAuth resCd="SplModify">
	<span id="isShowSplModifyBtn" />
</sys:funcAuth>
<!-- 是否显示狮桥分授权转换按钮 -->
<sys:funcAuth resCd="SplCiCfgModify">
	<span id="isShowSplCiCfgModifyBtn" />
</sys:funcAuth>
<!-- 是否显示操作日志 -->
<sys:funcAuth resCd="SplRiskLog">
	<span id="isSplRiskLog" />
</sys:funcAuth>

<script type="text/javascript">
    var grid = null;
    var _mfrId;
    var pageInApp={}; // to 下一级子窗口 接口
    var pageInTab=null;
    var currBuOrgCd = '${currBuOrgCd}';
    $(function () {
        initTab();
        _mfrId = '${mfrId}';
        var _url = '<%=path%>/product/splInfo/initList.do?isEncrypt=1&mfrId=' + _mfrId ;
        $("#ligergrid1").ligerGrid({
            url: _url,
			parms:{isBlackList:9},
            method : 'get',
            columns: [
                { display: '<span class="sqiconfont sqicon-tishi c_sqYellow gridTip" title="合同到期提醒"></span>',
                    name: '', minWidth: 30, align:'center', enabledSort:true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = '';
                        if(rowdata.isRemind == "1"){//合同到期提醒
                            h = '<i class="ico_flasher"></i>';
                        }else if(rowdata.isRemind == "2"){
                            h = '<i class="ico_flasher_blue"></i>';
                        }
                        return h;
                    }
				},
				{ display: '经销商ID', name: 'id', minWidth: 120, align:'center', enabledSort:true,hide:true
				},
                { display: '经销商名称', align:'left', width: 200,
                    render: function (rowdata, rowindex, value){
                        var h='<a href="javascript:showDetail(';
                        h+="'"+rowdata.id+"'";
                        h+=",'"+rowdata.audStsCd+"'";
                        h+=",'"+rowdata.qualTypCd+"'";
                        h+=",'"+rowdata.splAttrCd+"'";
                        h+=')">'+rowdata.splNm+'</a>';
                        return h;
                    }
                },
				{ display: '供应商星级', name: 'starLevelNm',width: 100},
				{ display: '供应商归属代码', name: 'ownerCd',width: 60,hide:true
				},
				{ display: '供应商归属', name: 'ownerCdNm',width: 100
				},
                { display: '供应商属性', name: 'splAttrCd',width: 60 ,
                    render: function (rowdata, rowindex, value){
                        if(StringUtils.isNotEmpty(value) && value==CustomerConstant.CST_TYPE_NP_CD){//1自然人 2法人
                            return "自然人";
                        }else if(StringUtils.isNotEmpty(value) && value==CustomerConstant.CST_TYPE_CORP_CD){
                            return "法人";
                        }else{
                            return "未知";
                        }
                    }
                },
				{ display: '经销商类型', name: 'prjLvlCdNm', align:'left', width: 150 },
				{ display: '营业执照号/证件号', name: 'succ', align:'left', width: 150 },
                { display: '所属机构', name: 'buOrgCdNms', align:'left', width: 200 ,isEllipsis: false,
                    render: function (rowdata, rowindex, value){
                        if(StringUtils.isEmpty(value)){
                            return "";
                        }else{
                            var h='<span class="gridTip" title="'+ value +'">'+ value +'</span>'
                            return h;
                        }
                    }
                },
                { display: '审核状态', width: 80,name: 'audStsCd',
                    render: function (rowdata, rowindex, value){
                        if(StringUtils.isNotEmpty(value)){
                            return rowdata.audStsCdNm ;
                        }else{
                            return '待提交';
                        }
                    }
                },
                { display: '是否黑名单', width: 80,name: 'isBlackList',
                    render: function (rowdata, rowindex, value){
                        if(StringUtils.isNotEmpty(value) && value == '1'){
                            return '是';
                        }else{
                            return "否";
                        }
                    }
                },
                { display: '流程编号', minWidth: 220,isEllipsis: false,
                    render: function (rowdata, rowindex, value){
                        if(rowdata && rowdata.sysFlowSHDTOList && rowdata.sysFlowSHDTOList.length==1){
                            var pno = rowdata.sysFlowSHDTOList[0].pno;
                            var audStsCd = rowdata.sysFlowSHDTOList[0].audStsCd;
                            var pinstId = rowdata.sysFlowSHDTOList[0].pinstId;
                            var dataId = rowdata.sysFlowSHDTOList[0].dataId;
                            if(StringUtils.isNotEmpty(pinstId)
                                && StringUtils.isNotEmpty(audStsCd)
                                && StringUtils.isNotEmpty(dataId)
                                && StringUtils.isNotEmpty(pno)){
                                var h='<a href="javascript:showFlow(';
                                h+="'"+pinstId+"'";
                                h+=",'"+audStsCd+"'";
                                h+=",'"+dataId+"'";
                                h+=')">'+pno+'</a>';
                                return h;
                            }
                        }else if(rowdata && rowdata.sysFlowSHDTOList && rowdata.sysFlowSHDTOList.length>1){
                            var h = "";
                            for(var i = 0;i < rowdata.sysFlowSHDTOList.length; i++) {
                                if(i!=0){
                                    h+='</br>';
                                }
                                var pno = rowdata.sysFlowSHDTOList[i].pno;
                                var audStsCd = rowdata.sysFlowSHDTOList[i].audStsCd;
                                var pinstId = rowdata.sysFlowSHDTOList[i].pinstId;
                                var dataId = rowdata.sysFlowSHDTOList[i].dataId;
                                h+='<a href="javascript:showFlow(';
                                h+="'"+pinstId+"'";
                                h+=",'"+audStsCd+"'";
                                h+=",'"+dataId+"'";
                                h+=')">'+pno+'</a>';
                                if(audStsCd == '1'){
                                    h+= ' - 审核中 ';
                                }else if(audStsCd == '2'){
                                    h += ' - 审核通过 ';
                                }else if(audStsCd == '3'){
                                    h += ' - 审核不通过 ';
                                }else if(audStsCd == '4'){
                                    h += ' - 驳回呈报人';
                                }
                            }
                            return h;
                        }
                    }
                },
				{ display: '供应商来源代码', name: 'splSource',width: 60,hide:true
				},
				{ display: '供应商来源', name: 'splSourceNm',width: 200
				},
				{ display: '周转换率%', name: 'splSlewRate',width: 200,
					render: function (rowdata, rowindex, value){
						if (value) {
							value = value + '%';
							var h='<a href="javascript:showSlewDetail(';
							h+="'"+rowdata.id+"'";
							h+=')">'+value +'</a>';
							return h;
						} else {
							return '-';
						}

					}
				},
				{ display: '代偿合同生效状态', name: 'compEffectIsValid',width: 200,
					render: function (rowdata, rowindex, value){
						if(value == 1){
							return "有效" ;
						}else if(value == 0){
							return "无效";
						}else{
							return '';
						}
					}
				},
                { display: '状态生效时间', name: 'effectiveTm', align:'center', width: 150,hide:true,
                    render: function (rowdata, rowindex, value){
                        if(StringUtils.isNotEmpty(rowdata.effectiveTm)){
                            return rowdata.effectiveTm ;
                        }else{
                            return '——';
                        }
                    }
                },
                { display: '续签状态', name: 'renewStsCd', align:'center', width: 150,hide:true,
                    render: function (rowdata, rowindex, value){
                        if(StringUtils.isNotEmpty(rowdata.renewStsCd) && rowdata.renewStsCd == '0'){
                            return '未续签';
                        }else if(StringUtils.isNotEmpty(rowdata.renewStsCd) && rowdata.renewStsCd == '1'){
                            return '续签中';
                        }else if(StringUtils.isNotEmpty(rowdata.renewStsCd) && rowdata.renewStsCd == '2'){
                            return '已续签' ;
                        }else if(StringUtils.isNotEmpty(rowdata.renewStsCd) && rowdata.renewStsCd == '3'){
                            return '续签不通过';
                        }else {
                            return '——';
                        }

                    }
                },
                { display: '续签时间', name: 'reAssignTm', align:'center', width: 150,hide:true,
                    render: function (rowdata, rowindex, value){
                        if(StringUtils.isNotEmpty(rowdata.reAssignTm)){
                            return rowdata.reAssignTm ;
                        }else{
                            return '——';
                        }
                    }
                },
                { display: '协议到期时间', name: 'protocolEndTm', align:'center', width: 150,hide:true,
                    render: function (rowdata, rowindex, value){
                        if(StringUtils.isNotEmpty(rowdata.protocolEndTm)){
                            return rowdata.protocolEndTm ;
                        }else{
                            return '——';
                        }
                    }

                },
                { display: '协议有效状态', name: 'isValid', align:'center', width: 150,hide:true,
                    render: function (rowdata, rowindex, value){
                        if(StringUtils.isNotEmpty(rowdata.isValid) && rowdata.isValid == '0'){
                            return '无效';
                        }else if(StringUtils.isNotEmpty(rowdata.isValid) && rowdata.isValid == '1'){
                            return '有效';
                        }else {
                            return '——';
                        }

                    }
                },
				getOptColumns(),
            ],
            pageSize:10,
            root:'rows',
            record:'total',
            hideLoadButton : true,
            width: '100%',
            height:'100%',
            heightDiff:-2,
            checkbox:true,
            fixedCellHeight: false,
            rownumbers:true,
//			onAfterShowData: getFlowIds,
        });
        grid = liger.get("ligergrid1");
        grid.setHeight(100);
        $("#searchBar").ligerForm();
        $('#reasonFromSet').ligerForm({
            validate : true
        });

        $("#searchBtn").click(function(event) {
            var form = new liger.get("searchBar");
            var data = form.getData();
            console.log(JSON.stringify(data));
            for (name in data){
                grid.setParm(name,data[name]);
            };
            grid.reload();
        });
        $("#clearBtn").click(function(event) {
            $("#resetBtn").click();  //重置 input-text
            var form = liger.get("searchBar");
            form.setData({  //重置select等特殊表单
                "brCd": " ",
                "audStsCd": " ",
                "rgnProvCd": " ",
                "rgnCityCd": " ",
                "buOrgCd": " ",
                "splTypCd": " ",
				"isBlackList":"9",
				"guarCd":" ",
				"compEffectIsValid":" ",
				"prjLvlCd":" "
            });
        });
    });

	function getOptColumns(){
		var col =  { display: '操作', width: 300 , align:'left',	isEllipsis: false,
			render: function (rowdata, rowindex, value){
				var opt = "";
				//发起审核 end
				var j='';/*'<a class="sq-button-hasicon" href="javascript:startSqlAdmissionFlow(';
				j+="'"+rowdata.id+"','"+rowdata.audStsCd+"','"+rowdata.isBlackList+"'";
				j+=')"><i class="sqBtnIco_4"></i>发起审核流程</a>';*/
				//提交
				var b='<a class="sq-button-hasicon" href="javascript:modifyAudStsCd(';
				b+="'"+rowdata.id+"'";
				b+=",'"+FlowConstant.FLOW_CHECK_STATE_IN+"'";
				b+=')"><i class="sqBtnIco_22"></i>提交</a>';
				//审核
				var h='<a class="sq-button-hasicon" href="javascript:changeAudStsCd(';
				h+="'"+rowdata.id+"'";
				if(StringUtils.isNotEmpty(rowdata.splAttrCd)){
					h+=",'"+rowdata.splAttrCd+"'";
				}else{
					h+=",''";
				}
				h+=')"><i class="sqBtnIco_6"></i>审核</a>';
				//供应商账号
				var bk='<a class="sq-button-hasicon" href="javascript:toSplBankList(';
				bk+="'"+rowdata.id+"'";
				bk+=')"><i class="sqBtnIco_1"></i>供应商账号</a>';
				//修改
				var g='<a class="sq-button-hasicon" href="javascript:change(';
				g+="'"+rowdata.id+"'";
				if(StringUtils.isNotEmpty(rowdata.splAttrCd)){
					g+=",'"+rowdata.splAttrCd+"'";
				}else{
					g+=",''";
				}
				g+=')"><i class="sqBtnIco_4"></i>修改</a>';
				//删除
				var d='<a class="sq-button-hasicon" href="javascript:deleteRecord(';
				d+="'"+rowdata.id+"'";
				d+=')"><i class="sqBtnIco_7"></i>删除</a>';

				var isShowCmtBtn = $("#isShowCmtBtn");
				var isShowAudBtn = $("#isShowAudBtn");
				var end = "";
				var audStsCd = "";
				if(rowdata && rowdata.sysFlowSHDTOList && rowdata.sysFlowSHDTOList.length>=1){
					audStsCd = rowdata.sysFlowSHDTOList[0].audStsCd;
				}else if(rowdata.audStsCd){
					audStsCd = rowdata.audStsCd ;
				}else if(!rowdata.sysFlowSHDTOList || rowdata.sysFlowSHDTOList.length==0){
					audStsCd = "0";
				}
				console.log("====="+audStsCd);
				//发起供应商准入流程 ---按钮提示
				if(isShowCmtBtn.length){
					if(audStsCd == FlowConstant.FLOW_CHECK_STATE_NON || audStsCd==FlowConstant.FLOW_CHECK_STATE_NO_PASS){
						end+=j;
					}
				}

				//有提交权限 && 审核状态:待提交||审核不通过  -->修改删除显示
				if(isShowCmtBtn.length ){
					if(audStsCd == FlowConstant.FLOW_CHECK_STATE_NON || audStsCd == FlowConstant.FLOW_CHECK_STATE_NO_PASS){
						opt += g;
						opt += d;
					}
				}

				/* zhaoyong 增加配置维护按钮 */
				var p='<a class="sq-button-hasicon" href="javascript:modifySplConfig(';
				p+="'"+rowdata.id+"'";
				p+=')"><i class="sqBtnIco_4"></i>配置维护</a>';
				var isShowConfigBtn = $("#isShowConfigBtn");
				if(isShowConfigBtn.length ){
					end += p;
				}
				/* zhaoyong 增加流程权限维护按钮 */
				var f='<a class="sq-button-hasicon" href="javascript:splBizFlowMdf(';
				f+="'"+rowdata.id+"'";
				f+=')"><i class="sqBtnIco_4"></i>流程权限维护</a>';

				var g1='<a class="sq-button-hasicon" href="javascript:changeData(';
				g1+="'"+rowdata.id+"'";
				if(StringUtils.isNotEmpty(rowdata.splAttrCd)){
					g1+=",'"+rowdata.splAttrCd+"'";
				}else{
					g1+=",''";
				}
				g1+=')"><i class="sqBtnIco_4"></i>变更</a>';

				var m='';
				//变更按钮显示
				var isShowSplModifyBtn = $("#isShowSplModifyBtn");
				if(isShowSplModifyBtn.length&&audStsCd == FlowConstant.FLOW_CHECK_STATE_PASS && rowdata.audStsCdNm != "变更审核中"){
					var strSplAttrCd=rowdata.splAttrCd;
					//只有法人才可以变更申请
					if(StringUtils.isNotEmpty(strSplAttrCd) && strSplAttrCd==CustomerConstant.CST_TYPE_CORP_CD){
						m = g1; //法人显示变更按钮
					}
				}
				var isShowSplBizFlowMdfBtn = $("#isShowSplBizFlowMdfBtn");
				if(isShowSplBizFlowMdfBtn.length && audStsCd == FlowConstant.FLOW_CHECK_STATE_PASS ){
					m += f;
				}
				end += m;
				var isSpeModify = $("#isSpeModify");
				if(isSpeModify.length && rowdata.audStsCd == '2' ){
					var ts='<a class="sq-button-hasicon" href="javascript:splSpePow(';
					ts+="'"+rowdata.id+"'";
					ts+=')"><i class="sqBtnIco_4"></i>特殊业务维护</a>';
					end+=ts ;
				}
				var isMdfBigCustomer = $("#isMdfBigCustomer");
				if(isMdfBigCustomer.length && rowdata.audStsCd == '2' && rowdata.splAttrCd == '2'){
					var ts='<a class="sq-button-hasicon" href="javascript:splSpePowBigCustomer(';
					ts+="'"+rowdata.id+"'";
					ts+=')"><i class="sqBtnIco_4"></i>大客户业务维护</a>';
					end+=ts ;
				}

				/**
				 *	发起合同续签按钮
				 */
				var rp = '<a class="sq-button-hasicon" href="javascript:toSplRenewProtocolPage(';
				rp += "'" + rowdata.id + "'";
				rp += ')"><i class="sqBtnIco_43"></i>合同续签</a>';
				// 重卡事业部展示合同续签按钮
				if(rowdata.buOrgCds && $.inArray("00000001", rowdata.buOrgCds) != -1) {
					end += rp;
				}
				end += bk;
                var isSplRiskLog = $("#isSplRiskLog");
                if (isSplRiskLog.length) {
                    var opLogBtn = '<a class="sq-button-hasicon" href="javascript:searchOpLog(';
                    opLogBtn += "'"+rowdata.id+"'";
                    opLogBtn += "," + "'" + rowdata.splNm + "'";
                    opLogBtn += ')"><i class="sqBtnIco_4"></i>操作日志</a>';
                    end += opLogBtn;
				}

				var isShowSplCiCfgModifyBtn = $("#isShowSplCiCfgModifyBtn");
				if (isShowSplCiCfgModifyBtn.length) {
					var ciConfigBtn='<a class="sq-button-hasicon" href="javascript:modifySplCiConfig(';
					ciConfigBtn+="'"+rowdata.id+"'";
					ciConfigBtn+=')"><i class="sqBtnIco_4"></i>狮桥分授权</a>';
					end += ciConfigBtn;
				}

				//return end + bk;
				return opt + SQ.dropLinks(end);
			}
		};
		return col;
	}


	//2017-7-12 15:28:57  jiangzg 显示数据之后，请求获取流程编号
    function getFlowIds() {
        var h = "";
        var pinstId = "";
        var audStsCd = "";
        var dataId = "";
        var pno = "";
        var jsonDatas = [];
        g = liger.get("ligergrid1");
        var dd = g.getData();
        var jsonData = JSON.stringify(dd);
        $.ajax({
            async: false,
            type: 'post',
            dataType: 'json',
            data: {data: jsonData, busTyp: "003"},
            url: '<%=path%>/product/splInfo/getSplSHFlowInfo.do',
            success: function (msg) {
                jsonDatas = JSON.stringify(msg);
            }
        });
//        console.log(g.columns.length);
        var oriData = eval("(" + jsonData + ")");
        var dataInfo = eval("(" + jsonDatas + ")");
        for(var c = 0;c<g.columns.length;c++){
            if(g.columns[c] != null && g.columns[c].name == 'pinstNm'){
//                console.log(g.columns[c]);
                var num = c ;
                for (var i = 0; i < oriData.length; i++) {
                    if (dataInfo[i].is_Flow_yesOrNo == "yes") {
                        pinstId = dataInfo[i].sysFlowSHDTO.pinstId;
                        audStsCd = dataInfo[i].sysFlowSHDTO.audStsCd;
                        dataId = dataInfo[i].sysFlowSHDTO.dataId;
                        pno = dataInfo[i].sysFlowSHDTO.pno;
                        if (StringUtils.isNotEmpty(pno)) {
                            h = '<a href="javascript:showFlow(';
                            h += "'" + pinstId + "'";
                            h += ",'" + audStsCd + "'";
                            h += ",'" + dataId + "'";
                            h += ')">' + pno + '</a>';
                        }
                        oriData[i].pinstNm = h;
                    } else {
                        oriData[i].pinstNm = "";
                    }
                    g.updateCell(num, oriData[i].pinstNm, i);
                }
                g.isDataChanged = false;
            }
            if(g.columns[c] != null && g.columns[c].name == 'audStsCdNm'){
//                console.log(g.columns[c]);
                var num = c ;
                for (var i = 0; i < oriData.length; i++) {
                    if (dataInfo[i].is_Flow_yesOrNo == "yes") {
                        audStsCd = dataInfo[i].sysFlowSHDTO.audStsCd;
                        oriData[i].audStsCdNm = audStsCd;
                        console.log("++++"+audStsCd);
                    } else {
                        oriData[i].audStsCdNm = "";
                        console.log("------"+audStsCd);
                    }
                    g.updateCell(num, oriData[i].audStsCdNm, i);
                }
                g.isDataChanged = false;
            }
        }
    }

    //显示流程
    function showFlow(_pInstId,_audStsCd,_businessKey){
        if(StringUtils.isEmpty(_pInstId)){
            UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
            return;
        }
        var _formUrl = "/product/splInfo/toDetailPage.do?isFlow=1@@id=";
        var params = "?pInsId="+_pInstId+"&status="+_audStsCd+"&businessKey="+_businessKey+"&formUrl="+_formUrl;
        Add_navTab('tab_spl_bank_flow_'+_pInstId,'查看流程',"<%=path%>/flow/flow/toFlowShowPageFowBus.do"+params);
    }

    //发起审核流程
    function startSqlAdmissionFlow(_id,_auditState,_isBlackList){
        if(!_id)return;
        if(StringUtils.isNotEmpty(_isBlackList) && _isBlackList == '1'){
            $.ligerDialog.SQalert({content:"标记为黑名单不允许发起审核流程.", SQ_type: "error"});
            return;
        }
        if(StringUtils.isNotEmpty(_auditState) && _auditState == '99'){
            $.ligerDialog.SQalert({content:"该供应商存在变更流程，请变更流程结束后再发起审核流程.", SQ_type: "error"});
            return;
        }
        //var modelTyp = FlowConstant.FLOW_MODEL_TYP_SPL_ACCESS;//流程业务分类-供应商准入
        var modelTyp = "033";//流程业务分类-供应商准入
        if(StringUtils.isEmpty(modelTyp)){
            console.log("modelTyp is null");
            return;
        }

        //$.ligerDialog.SQopen({
        //	width: 400,
        //    height:230,
        //    title : '操作原因',
        //    target : $('#reasonFromSet'),
        //    //url:'<%=path%>/spl/splOpLogRec/toAddBlackListReasonPage.do?splId='+_id,
        //    buttons: [{
        //        	text: "确定", type: 'ok', cls: 'l-dialog-btn-ok',
        //            onclick: function (item, Dialog) {
        //            		var form = new liger.get("reasonFromSet");
        //            		if (!form.valid()) {
        //            	    	top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
        //            	        return false; //验证不通过，不执行以下代码
        //            	    }
        continueStartSqlAdmissionFlow(_id,_auditState,modelTyp);
        //            		Dialog.hide();
        //            		$('#reason').val('');
        //            }
        //        }, {
        //            text: "取消", type: 'cancel', cls: 'l-dialog-btn-no',
        //            onclick: function (item, Dialog) {
        //            	Dialog.hide();
        //            	$('#reason').val('');
        //            }
        //        }
        //]
        //});
    }

    function continueStartSqlAdmissionFlow(_id,_auditState,_modelTyp){
        var reason = $('#reason').val();
        var flowDialog = $.ligerDialog.SQopen({
            url: '<%=path%>/flow/flow/toForStartListPage.do?modelTyp='+_modelTyp,
            width: 700,
            height:400,
            title : '请选择要发起的流程',
            buttons: [{
                text: "确定", type: 'ok', cls: 'l-dialog-btn-ok',
                onclick: function (item, Dialog) {
                    if (Dialog.onOk) {
                        $.ligerDialog.confirm('是否确定发起评审流程?', function (flag) {
                            if(flag == false) {
                                return;
                            }else{
                                Dialog.onOk();
                            }
                        })
                    }
                }
            }, {
                text: "取消", type: 'cancel', cls: 'l-dialog-btn-no',
                onclick: function (item, Dialog) {
                    if (Dialog.onCancel) Dialog.onCancel();
                }
            }
            ],
            onClose: function () {
                var json = flowDialog._DATA;
                console.log(json);
                if(!json){
                    return;
                }
                var wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting",onClose: function () {}});
                $.ajax({
                    type: 'post',
                    dataType:'json',
                    data:{
                        id:_id,
                        procDefKey:json.procDefKey,
                        procDefId:json.procDefId,
                        procNo:json.procNo,
                        reason:reason
                    },
                    url: '<%=path%>/product/splInfo/addFlowStart.do',
                    success:function(msg){
                        wait_dialog.close();
                        if(msg.success == 1){
                            $.ligerDialog.SQalert({content:msg.info, SQ_showButtons: true,SQ_type: "success",SQ_onBtnclick:function(){grid.reload();}});
                        }else{
                            UIUtils.alertErrorHold1(msg.info);
                        }
                    }
                });
            }
        });
    }

    //新增数据
    var callback = function () {
        grid.reload();
    };
    function add(){
        //弹出框校验供应商是否已存在
        $.ligerDialog.SQopen({
            width: 600,
            height:300,
            title : '供应商是否存在验证',
            url:'<%=path%>/product/splInfo/toCheckSplPage.do?mfrId='+_mfrId,
            /* buttons: [{
                text: "确定", type: 'ok', cls: 'l-dialog-btn-ok',
                onclick: function (item, Dialog) {
                    if (Dialog.onOk) Dialog.onOk();
                }
            }, {
                text: "取消", type: 'cancel', cls: 'l-dialog-btn-no',
                onclick: function (item, Dialog) {
                    if (Dialog.onCancel) Dialog.onCancel();
                }
            }
            ] */

        });
    }
    //审核
    function changeAudStsCd(_id,_splAttrCd){
        if(StringUtils.isEmpty(_id)) return;
        Add_navTab('PrdSpl_Aud'+_id,'审核供应商信息','<%=path%>/product/splInfo/toAddPage.do?isShowAuditBtn=1&id='+_id+'&splAttrCd='+_splAttrCd, callback);
    }
    //提交  修改审核状态(审核中)
    function modifyAudStsCd(_id,_audStsCd){
        if(!_id || !_audStsCd)return;
        //提交审核确认  2017-6-8 by YAOXIURONG
        $.ligerDialog.confirm(FlowConstant.SUBMIT_AUDIT_CONFIRM, function (flag) {
            if(flag == false)return;
            var url = '<%=path%>/product/splInfo/modifyAudStsCd.do';
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType:'json',
                data:{
                    id:_id,
                    audStsCd:_audStsCd
                },
                url: url,
                beforeSend: function(){
                    wait_dialog=top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
                },
                success:function(msg){
                    wait_dialog.close();
                    if(msg.success == 1){
                        top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                        grid.reload();
                    }else{
                        top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    }

    function toSplBankList(_id){
        if(!_id)return;
        Add_navTab('PrdSpl_4'+_id,'供应商账号',"<%=path%>/product/splBank/toListPage.do?splId="+_id);
    }
    //配置维护  zhaoyong 20170908
    function modifySplConfig(_id){
        if(!_id)return;
        Add_navTab('PrdSplConfig_'+_id,'配置维护','<%=path%>/product/splUsrR/toSingleConfigModifyPage.do?splId='+_id);
    };
    function splSpePow(_id){
    	if(!_id)return;
		Add_navTab('SplSpePow'+_id,'供应商特殊权限维护','<%=path%>/spl/spepow/toAddPage.do?splId=' + _id + '&isModify=1&needCloseTab=1');
	}
	function splSpePowBigCustomer(_id){
		if(!_id)return;
		Add_navTab('SplSpePow'+_id,'供应商特殊权限维护','<%=path%>/spl/spepow/toAddBigCustomerPage.do?splId=' + _id);
	}

	//狮桥分授权
	function modifySplCiConfig(_id){
		if(!_id)return;
		Add_navTab('PrdSplConfig_'+_id,'狮桥分授权','<%=path%>/spl/splcicfglog/toSplCiCfgModifyPage.do?splId='+_id);
	};

    //流程权限维护
    function splBizFlowMdf(_id){
        if(!_id)return;
        Add_navTab('splBizFlowMdf_'+_id,'流程权限列表','<%=path%>/bizflow/sysBizFlowRl/toAddAndApplyPage.do?saveBizFlowRl=1&saveNoSpNum=1&tabNm=SPL_BSC_INFO&codeGrpCd=FLW0001&dataId=' +_id+'&currBuOrgCd='+currBuOrgCd);
    };
    //修改数据
    function change(_id,_splAttrCd){
        if(!_id)return;
        if(_mfrId==""){
            Add_navTab('PrdSpl_2'+_id,'修改供应商','<%=path%>/product/splInfo/toAddPage.do?id='+_id+'&splAttrCd='+_splAttrCd+"&isModify=1&isShowBigCustomer=1", callback);
        }else{
            Add_navTab('PrdSpl_2'+_id,'修改供应商','<%=path%>/product/splInfo/toAddPage.do?id='+_id+'&mfrId='+_mfrId+'&splAttrCd='+_splAttrCd+"&isModify=1&isShowBigCustomer=1", callback);
        }
    };

    //审核通过后变更
    function changeData(_id,_splAttrCd) {
        Add_navTab('PrdSpl_2'+_id,'供应商信息变更','<%=path%>/product/splApplyInfo/toModifyPage.do?id='+_id+'&splAttrCd='+_splAttrCd+'&isApply=1', callback);
    }
    //详情
    function showDetail(_id,_audStsCd,_qualTypCd,_splAttrCd,_splNm){
        if(!_id)return;
        if(_mfrId==""){
            parent.mainApp.f_addTab('PrdSpl_3'+_id,'供应商详情','<%=path%>/product/splInfo/toDetailPage.do?id='+_id+'&splAttrCd='+_splAttrCd+'&audStsCd='+_audStsCd +"&qualTypCd="+_qualTypCd+"&isShowBigCustomer=1");
        }else{
            parent.parent.mainApp.f_addTab('PrdSpl_3'+_id,'供应商详情','<%=path%>/product/splInfo/toDetailPage.do?id='+_id+'&splAttrCd='+_splAttrCd+'&audStsCd='+_audStsCd+"&qualTypCd="+_qualTypCd+"&isShowBigCustomer=1");
        }
    }
	//周转换率详情
	function showSlewDetail(_id){
		if(!_id)return;
		Add_navTab('showSlewDetail'+_id,'周转换率详情','<%=path%>/product/splInfo/toSplLimRateDetailPage.do?splId='+_id, callback);
	}

    // 操作日志
    function searchOpLog(_id,_splNm){
        var url = '';
        url = '<%=path%>/risk/rskCstSignLog/toDetailListPage.do?cstId=' + _id + '&cstNm=' + _splNm + '&signSource=SPL&cstTypeCd=2&cstIdcard=';
        var title = '操作日志';
        $.ligerDialog.open({
            width: 1000,
            height: 500,
            title: title,
            url: url
        });
    }

    //到合同续签页面
    function toSplRenewProtocolPage(_splId){
        if (!_splId) return;
        parent.mainApp.f_addTab('SplRenewProtocol_1'+_splId,'合同续签','<%=path%>/spl/splReProtocol/toSplProtocolRecPage.do?splId='+_splId);
    }

    function modifyProtocol(operation){
        var selectedRows = grid.getSelectedRows();
        if (selectedRows.length != 1) {
            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
            return false;
        }
        var txt = "";
        if(StringUtils.isNotEmpty(operation) && operation =="stop"){
            txt = "确定终止协议吗?";
        }else{
            txt = "确定启用协议吗?";
        }
        $.ligerDialog.confirm(""+txt, function (flag) {
            if (!flag) return ;

            //console.log(selectedRows)
            var protocolId = selectedRows[0].protocolId;
            if(StringUtils.isNotEmpty(protocolId)){
                $.ajax({
                    type: 'post',
                    dataType:'json',
                    data:{protocolId:protocolId,operation:operation},
                    url: '<%=path%>/product/splInfo/modifyProtocolById.do',
                    beforeSend: function(){
                        wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
                    },
                    success:function(msg){
                        wait_dialog.close();
                        if(msg.success == 1){
                            $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                            grid.reload();
                        }else{
                            $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                        }
                    }
                });
            }else{
                $.ligerDialog.SQalert({content: "协议ID为空", SQ_type: "warning"});
            }
        });
    }
    //删除数据
    function deleteRecord(_id){
        if(!_id)return;
        var _ids = [];
        _ids.push(_id);
        $.ligerDialog.confirm('确定删除吗?', function (flag) {
            if(flag == false)return;
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType:'json',
                data:{ids:JSON.stringify(_ids)},
                url: '<%=path%>/product/splInfo/removeByIds.do',
                beforeSend: function(){
                    wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
                },
                success:function(msg){
                    wait_dialog.close();
                    if(msg.success == 1){
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                        grid.reload();
                    }else{
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    }
    function iframeResize () {
        if (parent.mainApp) {
            parent.mainApp.parentTab.onResize();
        };
    }
    //格式化时间
    function renderDate(rowdata, index, value){
        var dateStr = "";
        if(null != value){
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

    var loadedTabs = [];
    //初始化Tab页签
    function initTab(){
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onBeforeSelectTabItem: function(tabid) {
                var selectedRows = grid.getSelectedRows();
                if(tabid!="tabA"){
                    if (selectedRows.length != 1) {
                        $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
                        return false;
                    }
                }
            },
            onAfterSelectTabItem: function(tabid) {

                var selectedRows = grid.getSelectedRows();
                if(tabid!="tabA"){
                    if (selectedRows.length != 1) {
                        $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
                        return false;
                    }else{
                        if (loadedTabs.indexOf(selectedRows[0].id)<0) {
                            loadedTabs = [];
                            loadedTabs.push(selectedRows[0].id);
                            console.log(tabid);
                            switch (tabid){
                                case "tabB":
                                    console.log(tabid)
                                    pageInTab.setTabItemSrc(tabid, "<%=path%>/product/splInfo/toSplFlowPage.do?splId="+selectedRows[0].id);
                                    break;
                            }
                        }


                        SetIframe_height();
                    }
                }

            }
        });
        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });

    };
</script>

<body class="iframeBody">
<div class="Wrapper">
	<div id="pageInTab" class="pageInTab">
		<div tabid="tabA" title="供应商列表" lselected="true">
			<div class="searchArea">
				<form id="searchBar">
					<div class="fieldset1 clearFix">
						<div class="fieldBox">
							<div class="label">供应商名称</div>
							<div class="field">
								<input name="splNm" id="splNm" type="text" class="ui-textbox" value="">
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">供应商属性</div>
							<div class="field">
								<select name="splAttrCd" id="splAttrCd" data-value=" ">
									<option value=" " seleted>请选择</option>
									<c:forEach items="${splAttrCdList }" var="kv">
										<option value="${kv.key }">${kv.value }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">审核状态</div>
							<div class="field">
								<select name="audStsCd" id="audStsCd" data-value=" ">
									<option value=" " seleted>请选择</option>
									<c:forEach items="${searchAudStsCdList }" var="kv">
										<option value="${kv.key }">${kv.value }</option>
									</c:forEach>
									<option value="99">变更审核中</option>
								</select>
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">是否黑名单</div>
							<div class="field">
								<select name="isBlackList" id="isBlackList" data-value=" ">
									<option value="9" seleted>全部</option>
									<c:forEach items="${isOrNotBlackList }" var="kv">
										<option value="${kv.key }">${kv.value }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<c:if test="${currOrgCd == '0000' }">
							<div class="fieldBox">
								<div class="label">所属事业部</div>
								<div class="field">
									<select name="buOrgCd" id="buOrgCd" data-value=" ">
										<option value=" " seleted>请选择</option>
										<c:forEach items="${searchBuOrgList }" var="kv">
											<option value="${kv.key }">${kv.value }</option>
										</c:forEach>
									</select>
								</div>
							</div>
						</c:if>
						<c:if test="${currBuOrgCd != null and currBuOrgCd== '00000008'}">
							<div class="fieldBox">
								<div class="label">供应商类型</div>
								<div class="field">
									<select name="splTypCd" id="splTypCd" data-value=" ">
										<option value=" " seleted>请选择</option>
										<c:forEach items="${searchSplTypCdList}" var="kv">
											<option value="${kv.key }">${kv.value }</option>
										</c:forEach>
									</select>
								</div>
							</div>
						</c:if>
						<div class="fieldBox">
							<div class="label">区域</div>
							<div class="field">
								<div class="field">
									<jsp:include page="../../system/sysRegion/region.jsp" flush="true" >
										<jsp:param name="regionShowLvl" value="2"/>
									</jsp:include>
								</div>
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">协议到期日期</div>
							<div class="field">
								<input ligerui="width: 120" name="protocolTmStar"
									   id="protocolTmStar" type="text" class="ui-datepicker" value=""
									   validate="{required:true}"> - <input
									ligerui="width: 120" name="protocolTmEnd" id="protocolTmEnd"
									type="text" class="ui-datepicker" value=""
									validate="{required:true}">
							</div>
						</div>
						<div  class="fieldBox">
							<div class="label">协议有效状态</div>
							<div class = "field">
								<select name="isValid" id="isValid" data-value=" ">
									<option value=" " seleted>请选择</option>
									<option value="0">无效</option>
									<option value="1">有效</option>
								</select>
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">续签时间</div>
							<div class="field">
								<input ligerui="width: 120" name="reAssignTmStar"
									   id="reAssignTmStar" type="text" class="ui-datepicker" value=""
									   validate="{required:true}"> - <input
									ligerui="width: 120" name="reAssignTmEnd" id="reAssignTmEnd"
									type="text" class="ui-datepicker" value=""
									validate="{required:true}">
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">协议生效日期</div>
							<div class="field">
								<input ligerui="width: 120" name="effectiveTmStar"
									   id="effectiveTmStar" type="text" class="ui-datepicker" value=""
									   validate="{required:true}"> - <input
									ligerui="width: 120" name="effectiveTmEnd" id="effectiveTmEnd"
									type="text" class="ui-datepicker" value=""
									validate="{required:true}">
							</div>
						</div>
						<div  class="fieldBox">
							<div class="label">渠道担保业务</div>
							<div class = "field">
								<select name="guarCd" id="guarCd" data-value=" ">
									<option value=" " seleted>请选择</option>
									<option value="8">渠道保证金担保业务</option>
									<option value="9">代偿担保业务</option>
								</select>
							</div>
						</div>
						<div  class="fieldBox">
							<div class="label">代偿担保合同生效状态</div>
							<div class = "field">
								<select name="compEffectIsValid" id="compEffectIsValid" data-value=" ">
									<option value=" " seleted>请选择</option>
									<option value="0">无效</option>
									<option value="1">有效</option>
								</select>
							</div>
						</div>
						<div  class="fieldBox">
							<div class="label">经销商类型</div>
							<div class = "field">
								<select name="prjLvlCd" id="prjLvlCd" data-value=" ">
									<option value=" " checked >请选择</option>
									<option value="01">4S店</option>
									<option value="02">一级经销商</option>
									<option value="03">二级经销商</option>
									<option value="99">其他</option>
								</select>
							</div>
						</div>
						<div class="clearFix"></div>
						<div class="btnsBox formBtns notRight">
							<span id="searchBtn" class="sq-button-round">查询</span>
							<span id="clearBtn" class="sq-button-round">清空</span>
							<span id="addBtn" class="sq-button-round" onclick="add();">新增</span>
							<span id="addRenewBtn" class="sq-button-round" onclick="modifyProtocol('start')">协议启用</span>
							<span id="deleteRenewBtn" class="sq-button-round" onclick="modifyProtocol('stop')">终止协议</span>
							<input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
						</div>
					</div>
				</form>
			</div>
			<div class="sqPanel" style="margin-bottom: 0;">
				<div class="sqPanel_head" style="float:right;color: red">
					<table class="table_full">
						<tr>
							<td>
								<font color="blue"><i class="ico_flasher_blue"></i>合同到期前15天提醒</font>
								<font color="red"><i class="ico_flasher"></i>合同已经超期提醒</font>
							</td>
						</tr>
					</table>
				</div>
				<div class="sqPanel_body">
					<div id="ligergrid1" class="sq-grid"></div>
				</div>
			</div>

			<!-- 操作原因 -->
			<form id="reasonFromSet" style="display:none;">
				<div class="field">
					<textarea name="reason" id="reason" class="ui-textarea l-textarea" style="width:360px;height: 150px;" validate="{required:true}" ></textarea>
				</div>
			</form>
		</div>
		<div tabid="tabB" title="流程跟踪" id="tabBId">
			<iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
		</div>
	</div>
</div>

</body>
</html>